package controller;

import dao.BillDao;
import entity.SmbmsBll;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author: 举个栗子吖
 * @Date: 2019/11/12 10:21
 */
@Controller
@RequestMapping("/html")
public class UserBilllController {
    @Resource
    private BillDao billDao;

    @RequestMapping("/query")
    @ResponseBody
    public Map<String, Object> query(String userName, int offset, int limit) {
        SmbmsBll smbmsBll = new SmbmsBll();
        smbmsBll.setProductName(userName);
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> map1 = new HashMap<String, Object>();
        map.put("productName", userName);
        map.put("offset", (offset - 1) * limit);
        map.put("limit", limit);
        List<SmbmsBll> list = billDao.list(map);
        map1.put("total", billDao.query(smbmsBll));
        map1.put("rows", list);
        return map1;
    }

}
